package chapter7.shovel;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

/**
 * Created by uu on 2017/6/26.
 */
public class shovel_producer {
    public static void main(String[] args) throws Exception{
        ConnectionFactory factory =  new ConnectionFactory();
        factory.setUsername("guest");
        factory.setPassword("guest");
        factory.setVirtualHost("/");
        factory.setHost("localhost");
        factory.setPort(5675);
        Connection conn = factory.newConnection();
        final Channel channel = conn.createChannel();
        channel.exchangeDeclare("incoming_orders","direct",true,false,null);
        channel.queueDeclare("backup_orders",true,false,false,null);
        channel.queueBind("backup_orders","incoming_orders","warehouse");
        //channel.queueBind("incoming_orders","balance-exchange3","balance3",null);
        for(int i=0;i<10;i++) {
            channel.basicPublish("incoming_orders", "warehouse", true, null, String.valueOf(i).getBytes() );
        }
        channel.close();
        conn.close();
    }
}
